package com.kaifamiao.arrays;

// 遍历数组
public class Traversal {
    public static void main(String[] args) {

        char[] chars = { '春', '眠', '不', '觉', '晓' };
        // System.out.println( System.identityHashCode( chars ) );
        for( int i = 0, n = chars.length; i < n ; i++ ) {
            char ch = chars[i];
            System.out.println(ch);
        }

        System.out.println( "- ".repeat( 10 ) );

        // 显式创建"数组实例"并用"数组常量"初始化新数组
        chars = new char[]{'处', '处', '闻', '啼', '鸟'};
        // System.out.println( System.identityHashCode( chars ) );
        for( int i = chars.length - 1 ; i >= 0 ; i-- ) {
            char ch = chars[i];
            System.out.println(ch);
        }
    }
}
